Skip to content

Conversation

@bvolpato
Copy link
Contributor

@bvolpato bvolpato commented Oct 25, 2024

Which issue does this PR close?

Closes #13113.

Rationale for this change

Adding support to a new sort of expression (ORDER BY within aggregation functions) in the Substrait consumer.

For example:

SELECT ARRAY_AGG(genre ORDER BY genre) FROM book

What changes are included in this PR?

The wiring to go from Substrait's SortField to DataFusion's SortExpr in the context of aggregation measurements.

The actual conversion already existed at from_substrait_sorts because of window functions - I just hooked up in the context of aggragations as well.

Are these changes tested?

I added a roundtrip test and also added a logical plan to check if everything was decoded correctly. Open to more ideas on how to better unit test this.

Are there any user-facing changes?

n/a

@github-actions github-actions bot added the substrait Changes to the substrait crate label Oct 25, 2024
Copy link
Contributor

@vbarua vbarua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clear improvement with tests ✨

Thanks for fixing this.

@bvolpato bvolpato force-pushed the substrait-aggregate-expr branch 2 times, most recently from 3f11b77 to a44444e Compare October 25, 2024 20:11
Copy link
Member

@andygrove andygrove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @bvolpato

@bvolpato bvolpato force-pushed the substrait-aggregate-expr branch from 2e2c9fc to 224ddf4 Compare October 25, 2024 21:44
@bvolpato
Copy link
Contributor Author

LGTM. Thanks @bvolpato

Thank you! Sorry, I've missed a cargo fmt and we may need to trigger the checks again.

@alamb alamb merged commit d62f262 into apache:main Oct 29, 2024
24 checks passed
@alamb
Copy link
Contributor

alamb commented Oct 29, 2024

Thanks @bvolpato @vbarua and @andygrove

Sorry for the delay in merging this one

@alamb alamb mentioned this pull request Nov 5, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

substrait Changes to the substrait crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support ORDER BY in Substrait aggregate functions

5 participants